package com.daxue.bootckafka.send;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.kafka.core.KafkaProducerException;
import org.springframework.kafka.core.KafkaSendCallback;

/**
 * @author daxue0929
 * @date 2022/10/24
 */


@Data
@Slf4j
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class DefaultSendCallback implements KafkaSendCallback {

    public String serverName;

    @Override
    public void onFailure(KafkaProducerException ex) {
        log.error("{} message_send_error: {}", serverName, ex.getMessage());
    }

    @Override
    public void onSuccess(Object result) {
        log.info("[{}] message_send_success: {}", serverName, result.toString());
    }
}
